package com.lichuang.dedao.curriculum.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lichuang.dedao.curriculum.entity.Curriculum;
import com.lichuang.dedao.curriculum.entity.CurriculumType;
import com.lichuang.dedao.curriculum.service.impl.CurriculumServiceImpl;
import com.lichuang.dedao.curriculum.service.impl.CurriculumTypeServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaosong
 * @since 2019-07-15
 */
@RestController
@RequestMapping("/curriculum-type")
public class CurriculumTypeController {

    @Autowired
    private CurriculumTypeServiceImpl curriculumTypeService;

    @Autowired
    private CurriculumServiceImpl curriculumService;

    @RequestMapping("/getAllCurriculumType")
    public List<CurriculumType> getAllCurriculumType(){
        List<CurriculumType> types = curriculumTypeService.getAllCurriculumType(0);
        for (CurriculumType type : types) {
            QueryWrapper wrapper = new QueryWrapper();
            Curriculum curriculum = new Curriculum();
            curriculum.setCurriculumTypeParentid(type.getParentsId());
            wrapper.setEntity(curriculum);
            Integer count = curriculumService.count(wrapper);
            type.setCount(count);
        }
        return types;
    }


}
